<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <p>{{ msg }}</p>
      <p>{{ obj.a }}</p>
      <p>{{ obj.b }}</p>
      <button v-on:click="handleClick">btn</button>
    </div>

    <script src="../Vue.js"></script>
    <script>
      const data = {
        msg: "hello vue!",
        obj: {
          a: 3,
          b: null,
        },
      };

      // 将data里面的变量，向外移动一级，vm.msg就能拿到

      // 如果希望一个数据有响应式，那么一开始就定义这个数据的初始值
      const vm = new Vue({
        el: "#app",
        data: data,
        methods: {
          handleClick() {
            this.obj.b = 4;
          },
        },
      });
    </script>
  </body>
</html>
